<div style="min-height: 600px; height: auto;" id="test1" class="demo-tree demo-tree-box layui-font-18"></div>
<script src="/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript">
    Dcat.ready(function () {
        layui.use(['tree', 'util'], function(){
            var tree = layui.tree,
                layer = layui.layer,
                util = layui.util,
                data1 = {!! $menu !!}
          //常规用法
          tree.render({
            elem: '#test1' //默认是点击节点可进行收缩
            ,data: data1
            ,isJump: true
            ,click: function(obj){
                console.log(obj.data)
                if (obj.data.isParent) {
                    let url = obj.data.url;
                    window.location.href=url
                    return;
                } else {
                    let reg = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/;
                    if (!reg.test(obj.data.id)) {   
                        let url = obj.data.url;
                        window.location.href=url
                    }
                }
                console.log(obj.data); //得到当前点击的节点数据
                console.log(obj.state); //得到当前节点的展开状态：open、close、normal
                console.log(obj.elem); //得到当前节点元素
                console.log(obj.data.children); //当前节点下是否有子节点
              }
          });
        });
    });
</script>